<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .mask{
      position: fixed;
      left: 0;
      right: 0;
      top: 0;
      bottom:0;
      background-color: rgba(0,0,0,.7);
      z-index: 100;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .content{
      width: 40%;
      height: 40%;
      background-color: #fff;
    }
  </style>
</head>
<body>
  <div id="app">
    <home-page></home-page>
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp();
    const HomePage = {
      template:`
        <div class="home-container">
          <button @click="showModal">按钮</button>
          <Teleport to="body">
            <div class="mask" @click.self="hideModal" v-show="isShow">
              <div class="content">
                弹窗 内容 
              </div>  
            </div>
          </Teleport>
        </div>
      `,
      data() {
        return {
          isShow: false
        }
      },
      methods: {
        showModal() {
          this.isShow = true;
        },
        hideModal () {
          this.isShow = false;
        }
      },
    }

    app.component('HomePage', HomePage)
    app.mount('#app')
  </script>
</body>
</html>